<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html lang="en">
<script type="text/javascript" src="/cooknote/resources/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function() {

		 $.ajax({
// 		        datatype:"json",
		        type: "POST",
// 		        type: "GET",
// 		        url: "/cooknote/user_list",
		        url: "/cooknote/user_list.json",
// 		        url: "/cooknote/user_list.xml",
// 		        contentType: "application/xml",
// 		        data: $("#frmtest").serialize(),
		        success: function(response)
		        {
		            console.log(response);

		            var user_id;

		    		$.each(response, function(index, obj) {

		    			//참고 		var reg_date = dateFormat( isNullStr( obj.reg_date ), "-" ); // (등록일)

		    						clonedRow = $("#target_table > tbody >tr:first").clone(true).addClass("template_real");

									user_id = obj.user_id;

		    						$(clonedRow.find("#no_text")).text( index );

		    						$(clonedRow.find("#user_id")).wrapInner( function() {
		    							var link = $("<a/>");
		    							link.text(user_id);
		    							link.attr("href", "javascript:go_detail('" + user_id.toString() + "')");
// 		    							$(link).wrapInner("<b></b>");
		    							$(link).wrapInner("<font color='blue'></font>");
		    							return link;
		    						}); //(제목)

		    						clonedRow.appendTo("#target_table");

		    					});

		        },
		        error: function(e)
		        {
		            console.log('Error: ' + e);
		        }
		    });

});


//관리자 - 공지사항 상세 화면으로 이동
function go_detail(user_id){


	$('#user_id').val(user_id);
	$('#frmtest').attr('method','GET')
	$('#frmtest').attr('action','/cooknote/user_detail_form').submit();

// 	 $.ajax({
// 	        datatype:"json",
// 	        type: "POST",
// 	        url: "/cooknote/user_detail",
// 	        data: $("#frmtest").serialize(),
// 	        success: function(response)
// 	        {
// 	            console.log(response);

// 	        },
// 	        error: function(e)
// 	        {
// 	            console.log('Error: ' + e);
// 	        }
// 	    });

}

function go_create(){
	$('#frmtest').attr('method','GET')
	$('#frmtest').attr('action','/cooknote/user_create_form').submit();
}

</script>

<body>


${user.user_id}


<form id="frmtest" name="frmtest">
	<input type="text" name="user_id" id="user_id" />
</form>

<div class="container">
    <h2>Members</h2>
	<table id="target_table" class="target_table_css" summary="공지사항 리스트">
		<thead>
			<tr>
				<th>번호</th>
				<th>아이디</th>
				<th>닉네임</th>
			</tr>
		</thead>
		<tbody>
			<tr id="temp_tr">
				<td><span id="no_text"></span></td>
				<td><span id="user_id"></span></td>
				<td><span id="nick_name"></span></td>
			</tr>
		</tbody>
	</table>

<br/>
<br/>
	<table>
			<tbody>
				<tr>

					<td>
						<a href="#" onclick="javascript:go_create();">등록</a>
					</td>
				</tr>
			</tbody>
	</table>
</div>
</body>

</html>
